import React, { Component } from 'react';
import {
    Platform,
    StyleSheet,
    Text,
    View,
    Button,
    Image
} from 'react-native';
import { StackActions, NavigationActions } from 'react-navigation';
//导入启动屏幕
import SplashScreen from 'react-native-splash-screen';
const resetAction = StackActions.reset({
    index: 0,
    actions: [NavigationActions.navigate({ routeName  : 'TabNav' })],
});

// 测试图片裁剪页
const resetActionText = StackActions.reset({
    index: 0,
    actions: [NavigationActions.navigate({ routeName  : 'Test' })],
});

export default class WelcomePage extends Component {
    constructor(props){
        super(props);
    }
    componentDidMount(){
        this.timer = setTimeout(()=>{
            SplashScreen.hide();
            this.props.navigation.dispatch(resetAction);
        }, 200)
    }
    componentWillUnmount(){
       this.timer && clearTimeout(this.timer);
    }
    render(){
        return (
            <View style={styles.container}>
                <Image
                    style={styles.backgroundImage}
                    source={require('../res/images/setup.jpg')}
                />
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
    },
    backgroundImage:{
        flex:1,
        alignItems:'center',
        justifyContent:'center',
        width:null,
        height:null,
        //不加这句，就是按照屏幕高度自适应
        //加上这几，就是按照屏幕自适应
        //resizeMode:Image.resizeMode.contain,
        //祛除内部元素的白色背景
        backgroundColor:'rgba(0,0,0,0)',
    }
})